/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.trader.utils;

import ca.trader.except.InvalidEmailAddressException;
import ca.trader.except.PasswordLengthException;
import ca.trader.user.User;
import java.util.regex.Pattern;

/**
 *
 * @author Ahsan
 */
public class UserValidationUtils
{
	 private static final int MIN_PASSWORD_LENGTH = 6;
	 private static final int MAX_PASSWORD_LENGTH = 15;
	 public static final Pattern emailRegex = Pattern.compile("[a-zA-z](\\.?[\\w])*[@]((\\w)+\\.)+[a-zA-Z]{2,4}");

	 public static void validateUser (User user, String password) throws PasswordLengthException, InvalidEmailAddressException
	 {
		  if (password.length() < MIN_PASSWORD_LENGTH || password.length() > MAX_PASSWORD_LENGTH)
		  {
			   throw new PasswordLengthException (MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH);
		  }
		  
		  //if (emailRegex.matcher(user.getEmail()).find())
		  //{
		//	   throw new InvalidEmailAddressException (user.getEmail());
		 // }
	 }
	 
}
